<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function addArr(x,y,z) {
      return x + y + z
    }

    function dyCurry(fn) {
      function curried(...arr) {
        if(arr.length >= fn.length) {
          return fn.apply(null,arr)
        }
        else {
          function curried1(...arr1) {
            return curried.apply(null,arr.concat(arr1)) 
          }
          return curried1
        }
      }
      return curried
    }
    let newArr = dyCurry(addArr)
    console.log(newArr(10,20,30));
    console.log(newArr(10)(20,30));
    console.log(newArr(10)(20)(30));
  </script>
</body>
</html>